// import jsonp from '@/common/js/jsonp'
// import {commonParams, options} from './config'

// export function getRecommend () {
//   const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'

//   const data = Object.assign({}, commonParams, {
//     platform: 'h5',
//     uin: 0,
//     needNewCode: 1
//   })

//   return jsonp(url, data, options)
// }

// export function getDiscList () {
//   const url = '/api/getDiscList'

// const data = Object.assign({}, commonParams, {
//   platform: 'yqq',
//   hostUin: 0,
//   sin: 0,
//   ein: 29,
//   sortId: 5,
//   needNewCode: 0,
//   categoryId: 10000000,
//   rnd: Math.random(),
//   format: 'json'
// })

//   return axios.get(url, {
//     params: data
//   }).then((res) => {
//     return Promise.resolve(res.data)
//   })
// }

import axios from 'axios'

export const commonParams = {
  g_tk: 1928093487,
  inCharset: 'utf-8',
  outCharset: 'utf-8',
  notice: 0,
  format: 'jsonp'
}

export const ERR_OK = 0

// 首页轮播

export function getList () {
  const url = '/api/recommend'
  const data = Object.assign({}, commonParams, {
  // STARTPF_CODE:apiURL,
    platform: 'h5',
    uin: 0,
    needNewCode: 1
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    // console.log(res)
    return Promise.resolve(res.data)
  })
}

// 首页列表

export function getmusic () {
  const url = '/api/name'
  const data = Object.assign({}, commonParams, {
  // STARTPF_CODE:apiURL,
    platform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    // console.log(res)
    return Promise.resolve(res.data)
  })
}
// 歌手列表
export function getSingerList () {
  const url = '/api/singer'
  const data = Object.assign({}, commonParams, {
    channel: 'singer',
    page: 'list',
    key: 'all_all_all',
    pagesize: 100,
    pagenum: 1,
    hostUin: 0,
    needNewCode: 0,
    platform: 'yqq'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    // console.log(res)
    return Promise.resolve(res.data)
  })
}
